'use strict';

module.exports = app => {
  const mongoose = app.mongoose
  const UserSchema = new mongoose.Schema(
    {
      name: { // 真实姓名
        type: String,
        default: '小明'
      },
      mobile: { // 手机号
        type: String,
        required: true
      },
      code: { // 密码
        type: String
      },
      avatarUrl: { // 用户头像
        type: String,
        default: 'http://81.68.73.55/group1/M00/00/08/rBEAA2ALmXqAeyy8AABeLYDLZrg150.png'
      },
      sex: { // 性别
        type: String,
        enum: ['男', '女'],
        default: '男'
      },
      role: { // 角色
        type: String,
        enum: ['student', 'admin'],
        default: 'student'
      }
    },
    {
      // 时间戳
      timestamps: {
        createAt: 'createAt',
        updateAt: 'updateAt'
      }
    }
  )
  return mongoose.model('User', UserSchema)
};
